package mvc.util;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

public class SetClassEntity {
    
    
    public  static Object serEntity(HttpServletRequest request){
        
        Object o = null;
        try{
        Class clzz = Class.forName(request.getParameter("classname"));
        o = clzz.newInstance();
        Field[] file = clzz.getDeclaredFields();
        System.out.println(file.length);
        for(Field f:file){
            f.setAccessible(true);
            f.set(o, request.getParameter(f.getName()));
            f.setAccessible(false);
            }
        }catch(Exception e){
            e.printStackTrace();
        }
        return o;
    }

}
